package com.hqyj.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import tk.mybatis.mapper.annotation.KeySql;

import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
import java.util.List;

@Data
@Table
public class Product {
    @Id
    @KeySql(useGeneratedKeys = true)
    private Integer id;

    private Integer categoryId;

    private String name;

    private String subTitle;

    private Double originalPrice;

    private Double promotePrice;

    private Integer stockCount;

    private Integer saleCount;

    private Integer merchantId;//商家ID

    private Integer number;

    private Integer reviewCount;

    private String seller;

    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date createDate;

    private ProductImage productImage;

    private List<ProductImage> productImages;


    private OrderItem orderItem;


    public Product(Integer id, Integer categoryId, String name, String subTitle, Double originalPrice, Double promotePrice, Integer stockCount, Integer saleCount, Integer number, Integer reviewCount, String seller, Date createDate, List<ProductImage> productImages) {

        this.id = id;
        this.categoryId = categoryId;
        this.name = name;
        this.subTitle = subTitle;
        this.originalPrice = originalPrice;
        this.promotePrice = promotePrice;
        this.stockCount = stockCount;
        this.saleCount = saleCount;
        this.number = number;
        this.reviewCount = reviewCount;
        this.seller = seller;
        this.createDate = createDate;
        this.productImages = productImages;
    }

    public Product() {
    }

    @Override
    public String toString() {
        return "Product{" +
                "id=" + id +
                ", categoryId=" + categoryId +
                ", name='" + name + '\'' +
                ", subTitle='" + subTitle + '\'' +
                ", originalPrice=" + originalPrice +
                ", promotePrice=" + promotePrice +
                ", stockCount=" + stockCount +
                ", saleCount=" + saleCount +
                ", number=" + number +
                ", reviewCount=" + reviewCount +
                ", seller='" + seller + '\'' +
                ", createDate=" + createDate +
                ", productImages=" + productImages +
                '}';
    }
}